package yuewen

import (
	"gitee.com/leo-xin/novel_distribution_sdk_go/common/middleware"
	"gitee.com/leo-xin/novel_distribution_sdk_go/yuewen/api"
	"gitee.com/leo-xin/novel_distribution_sdk_go/yuewen/config"
)

type Client struct {
	ApiClient *api.APIClient
}

func (c *Client) UseWechat() *Client {
	c.ApiClient.Cfg.SetPrefix("wechat")
	return c
}

func (c *Client) UseQuickApp() *Client {
	c.ApiClient.Cfg.SetPrefix("quickapp")
	return c
}

func (c *Client) UseDuanPian() *Client {
	c.ApiClient.Cfg.SetPrefix("duanpian")
	return c
}

func (c *Client) UseMoXiang() *Client {
	c.ApiClient.Cfg.SetPrefix("moxiang")
	return c
}

func Init(cfg *config.Configuration) *Client {
	client := &Client{
		ApiClient: api.NewAPIClient(cfg),
	}

	if cfg.LogEnable {
		client.ApiClient.Use(middleware.LogMiddleware)
	}

	return client
}

func (c *Client) GetAppListV2Api() *api.GetAppListApiService {
	return c.ApiClient.GetAppListV2Api
}

func (c *Client) BookGetNovelInfoApi() *api.BookGetNovelInfoApiService {
	return c.ApiClient.BookGetNovelInfoApi
}

func (c *Client) BookGetFreeChapterListApi() *api.BookGetFreeChapterListApiService {
	return c.ApiClient.BookGetFreeChapterListApi
}

func (c *Client) BookGetSpreadListApi() *api.BookGetSpreadListApiService {
	return c.ApiClient.BookGetSpreadListApi
}

func (c *Client) UserGetUserInfoApi() *api.UserGetUserInfoApiService {
	return c.ApiClient.UserGetUserInfoApi
}

func (c *Client) RechargeGetRechargeLogApi() *api.RechargeGetRechargeLogApiService {
	return c.ApiClient.RechargeGetRechargeLogApi
}
